﻿using Che.AppService.AppService.Itrophy;
using Che.AppService.AppService.Login;
using Che.AppService.Dto;
using Che.Domain.Entity.Che.User;
using Che.Domain.Entity.EventsBut;
using Che.Domain.Entity.trophy;
using Microsoft.AspNetCore.Mvc;

namespace Che.WebApi.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class trophyController : ControllerBase
    {
        private readonly APPItrophy iu;
        private readonly ILogger<LoginController> _logger;
        public trophyController(APPItrophy iu, ILogger<LoginController> logger)
        {
            this.iu = iu;
            _logger = logger;
        }
        [HttpGet]
        public Task<List<trophyq>> trophyqs()
        {
          
                 return iu.trophyqs();
        
        }
        [HttpGet("event-details")]
        public Task<List<EventDetail>> EventDetailqu()
        {

            return iu.EventDetailque();

        }
        [HttpGet("event-ADDtrd")]
        public Task<List<FootballAdd>> footballAddsquest()
        {

            return iu.footballAddsquest();

        }
        [HttpGet("event-football")]
        public Task<List<Stadium>> footballs()
        {

            return iu.footballs();

        }
        [HttpGet("event-Events")]
        public Task<List<EventType>> eventTypes()
        {

            return iu.eventTypes();

        }
        [HttpPost("addenven")]
        public async Task<IActionResult> enventadd([FromBody] Event en)
        {
            try
            {
                if (en == null )
                {
                    return BadRequest("不能为空");
                }

                // 调用服务层进行登录验证
                var result = await iu.addEvents(en);

                if (result == null)
                {
                    return Unauthorized("加入失败");
                }

                // 登录成功，返回用户信息
                return Ok(result);
            }
            catch (Exception ex)
            {
                // 记录日志
                return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
            }
        }
    }
}
